package com.todomvc.fw;

import java.util.Properties;

public class ApplicationManager {

	private static ApplicationManager singleton;

	private WebDriverHelper webDriverHelper;
	private NavigationHelper navigationHelper;
	private TodoHelper todoHelper;

	private Properties props;

	public static ApplicationManager getInstance() {
		if (singleton == null) {
			singleton = new ApplicationManager();
		}
		return singleton;
	}

	public void stop() {
		if (webDriverHelper != null) {
			webDriverHelper.stop();
		}
	}
	
	public void setProperties(Properties props) {
		this.props = props;
	}
	
	public String getProperty(String key) {
		return props.getProperty(key);
	}

	public String getProperty(String key, String defaultValue) {
		return props.getProperty(key, defaultValue);
	}

	public WebDriverHelper getWebDriverHelper() {
		if (webDriverHelper == null) {
			webDriverHelper = new WebDriverHelper(this);
		}
		return webDriverHelper;
	}

	public NavigationHelper getNavigationHelper() {
		if (navigationHelper == null) {
			navigationHelper = new NavigationHelper(this);
		}
		return navigationHelper;
	}

	public TodoHelper getTodoHelper() {
		if (todoHelper == null) {
			todoHelper = new TodoHelper(this);
		}
		return todoHelper;
	}

}
